# Maintainer: Pedro Lucas Porcellis <porcellis@eletrotupi.com>
pkgname=satellite
pkgver=1.0.0
pkgrel=23
pkgdesc="Satellite is a small Gemini server for serving static files"
url="https://git.sr.ht/~gsthnz/satellite"
arch="all"
license="AGPL-3.0-or-later"
subpackages="$pkgname-openrc $pkgname-doc"
makedepends="go scdoc"
install="$pkgname.pre-install"
source="
	$pkgname-$pkgver.tar.gz::https://git.sr.ht/~gsthnz/satellite/archive/v$pkgver.tar.gz
	$pkgname.initd
	$pkgname.confd
"
pkggroups="satellite"
builddir="$srcdir/$pkgname-v$pkgver"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	make
}

check() {
	go test ./...
}

package() {
	install -Dm755 $pkgname "$pkgdir"/usr/bin/$pkgname
	install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
	install -Dm644 "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname

	install -Dm640 -o root -g satellite "$builddir"/$pkgname.toml \
		"$pkgdir"/etc/$pkgname.toml

	install -Dm644 doc/satellite.1 "$pkgdir"/usr/share/man/man1/satellite.1
	install -Dm644 doc/satellite.toml.5 "$pkgdir"/usr/share/man/man5/satellite.toml.5
}

sha512sums="2b14e6bd7a1b33a0b4cf402e64585f9f87d2491709bd2f383ec0777b24a372fa7360ca7da96d21e61790095554c8029b07cdddc7a23688465ee77f7854beea48  satellite-1.0.0.tar.gz
dcf84f7f09651426189280df73ce683b5a88bc40764e1ae5e0993fe2d9a796e36437c5f064fae120d749f8fd0151ef11296210556408a04441fc01e571f8f6cb  satellite.initd
f20f287640743ede9139a12fb7cbbcc9f2f51bc179322e04253e236daf55090aa043e9e01ec7f29cadc965cdb73bbaa86080072840913c88503138df8a04e443  satellite.confd"
